/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.fredy.filerenamer.ui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ResourceBundle;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;

import net.miginfocom.swing.MigLayout;

/**
 * About dialog.
 * @author fredy
 */
public class AboutDialog extends JDialog {

    private static final long serialVersionUID = 1L;
    private final ResourceBundle rb;
    private JLabel applicationLabel;
    private JLabel authorNameLabel;
    private JLabel copyrightLabel;
    private JButton okButton;

    public AboutDialog(ResourceBundle rb) {
        this.rb = rb;
        setLayout(new MigLayout("", "[center]", ""));
        setTitle(rb.getString(ResourceBundleKey.LABEL_ABOUT.toString()));
        setResizable(false);
        setModal(true);
        setDefaultCloseOperation(HIDE_ON_CLOSE);
        initComponents();
        pack();
    }

    private void initComponents() {
        applicationLabel = new JLabel(rb.getString(
                ResourceBundleKey.LABEL_APPLICATION.toString()));
        applicationLabel.setFont(new java.awt.Font("Tahoma", 1, 18));
        add(applicationLabel, "wrap");

        authorNameLabel = new JLabel(rb.getString(
                ResourceBundleKey.LABEL_AUTHOR.toString()));
        add(authorNameLabel, "wrap");

        copyrightLabel = new JLabel(rb.getString(
                ResourceBundleKey.LABEL_COPYRIGHT.toString()));
        add(copyrightLabel, "wrap");

        okButton = new JButton(rb.getString(ResourceBundleKey.LABEL_OK.toString()));
        okButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                setVisible(false);
            }
        });
        add(okButton, "wrap");
    }
}
